#pragma once
#include "DXAMLCommon.h"
#include "CControl.h"

class CPanel;
class CString;
class CItemsPresenter;
class CItemsPanelTemplate;
class CItemCollection;

class CItemsControl :
	public CControl
{

private: 
	CItemsControl(CCoreServices * pCore);
private: 
	virtual ~CItemsControl();
public: 
	static HRESULT Create(CDependencyObject * * ppObject, CREATEPARAMETERS * pCreate);
	virtual XUINT32 GetTypeIndex() const;
	virtual HRESULT SetValue(CDependencyProperty * pdp, CValue * pValue);
	virtual HRESULT ClearValue(CDependencyProperty * pdp);
	virtual HRESULT CreationComplete();
protected: 
	virtual XBOOL CanEnterImpl(CDependencyObject * pNamescopeOwner);
	virtual HRESULT EnterImpl(CDependencyObject * pNamescopeOwner, struct EnterParams params);
	virtual HRESULT LeaveImpl(CDependencyObject * pNamescopeOwner, struct LeaveParams params);
	virtual HRESULT MeasureOverride(struct XSIZEF availableSize, struct XSIZEF & desiredSize);
	virtual HRESULT ApplyTemplate(XBOOL & fAddedVisuals);
public: 
	static HRESULT GetItems(struct Xcp_IDependencyObject * pObject, XUINT32 cArgs, CValue * ppArgs, CValue * pResult);
public: 
	XBOOL IsUsingItemsSource();
private: 
	HRESULT InvalidateItemsHost(XBOOL bHostIsReplaced);
	CItemsPresenter * RegisterItemsPresenter(CItemsPresenter * pItemsPresenter);
	HRESULT ValidateItemsHost();
	HRESULT EnsureItemCollection();
public: 
	CItemCollection * m_pItemCollection;
	CPanel * m_pItemsHost;
	XBOOL m_bItemsHostInvalid;
	CDataTemplate * m_pItemTemplate;
	CString * m_pDisplayMemberPath;
	CItemsPanelTemplate * m_pItemsPanelTemplate;
	CStyle * m_pItemContainerStyle;
	CTransitionCollection * m_pItemContainerTransitions;
private: 
	CItemsPresenter * m_pItemsPresenter;
	XBOOL m_bItemsSourceActive;
	XBOOL m_bItemsHostIsSetFromManaged;


};